//
//  HMUserAccount.m
//  OC新浪微博
//
//  Created by wyman on 16/4/12.
//  Copyright © 2016年 wyman. All rights reserved.
//

#import "HMUserAccount.h"

@implementation HMUserAccount
+(instancetype)initWithDict:(NSDictionary *)dict
{
//字典转模型
    id obj = [[self alloc]init];
    
    [obj setValuesForKeysWithDictionary:dict];


    return obj;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{

}

-(void)setExpires_in:(NSTimeInterval)expires_in
{
    _expires_in = expires_in;

    self.expiresDate = [NSDate dateWithTimeIntervalSinceNow:expires_in];
}

#pragma mark 归档解档方法

//解档
-(void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeDouble:self.expires_in forKey:@"expires_in"];

    [aCoder encodeObject:self.access_token forKey:@"expiresDate"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.screen_name forKey:@"screen_name"];

    [aCoder encodeObject:self.avatar_large forKey:@"avatar_large"];


}

//归档
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
   
    
    self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
    self.expiresDate = [aDecoder decodeObjectForKey:@"expiresDate"];
    self.uid = [aDecoder decodeObjectForKey:@"uid"];

    self.expires_in = [aDecoder decodeDoubleForKey:@"expires_in"];

    self.screen_name = [aDecoder decodeObjectForKey:@"screen_name"];

    self.avatar_large = [aDecoder decodeObjectForKey:@"avatar_large"];

    return self;
}

@end
